package day0310;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Demo02 {

    public static void main(String[] args) {
        String[] str = {"gin", "zen", "gig", "msg"};
        System.out.println(count(str));
    }

    public static int count(String[] words) {
        // words = ["gin", "zen", "gig", "msg"]
        String[] m = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};

        Set set = new HashSet();

        for (int i = 0; i < words.length; i++) {
            StringBuilder result = new StringBuilder();
            for (int j = 0; j < words[i].length(); j++) {
                char c = words[i].charAt(j);
                result.append(m[c - 97]);
            }
            set.add(result.toString());
        }
        return set.size();
    }
}
